#include "form.h"
#include "ui_form.h"
#include <QPainter>
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->label->installEventFilter(this);

    ui->setupUi(this);
    Form form;
    form.show();
}

Form::~Form()
{
    delete ui;
}

bool Form::eventFilter(QObject *watched, QEvent *event)
{
    if(watched==ui->label&&event->type()==QEvent::Paint)
    {
        on_pushButton_clicked();
    }
    return Form::eventFilter(watched,event);
}

void Form::on_pushButton_clicked()
{
    QPainter painter(this);
    QImage img(":/avatar.png");
    QRectF r{40,40,100,200};
    painter.drawImage(r,img);
}
